package edu.gdkm.dao;

import edu.gdkm.pojo.CompanyInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;

public interface CompanyInfoDAO {
    
    // 根据ID查询公司信息
    @Select("SELECT * FROM company_info WHERE id = #{id}")
    CompanyInfo findById(Long id);
    
    // 根据用户ID查询公司信息
    @Select("SELECT * FROM company_info WHERE user_id = #{userId}")
    CompanyInfo findByUserId(Long userId);
    
    // 根据公司名称查询公司信息
    @Select("SELECT * FROM company_info WHERE company_name = #{companyName}")
    List<CompanyInfo> findByCompanyName(String companyName);
    
    // 查询所有公司信息
    @Select("SELECT * FROM company_info")
    List<CompanyInfo> findAll();
    
    // 根据行业查询公司信息
    @Select("SELECT * FROM company_info WHERE industry = #{industry}")
    List<CompanyInfo> findByIndustry(String industry);
    
    // 插入公司信息
    @Insert("INSERT INTO company_info(user_id, company_name, industry, scale, nature, introduction, " +
            "address, website, contact_person, create_time, update_time) " +
            "VALUES(#{userId}, #{companyName}, #{industry}, #{scale}, #{nature}, #{introduction}, " +
            "#{address}, #{website}, #{contactPerson}, #{createTime}, #{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(CompanyInfo companyInfo);
    
    // 更新公司信息
    @Update("UPDATE company_info SET user_id=#{userId}, company_name=#{companyName}, industry=#{industry}, " +
            "scale=#{scale}, nature=#{nature}, introduction=#{introduction}, address=#{address}, " +
            "website=#{website}, contact_person=#{contactPerson}, update_time=#{updateTime} WHERE id=#{id}")
    int update(CompanyInfo companyInfo);
    
    // 根据ID删除公司信息
    @Delete("DELETE FROM company_info WHERE id = #{id}")
    int deleteById(Long id);
    
    // 根据用户ID删除公司信息
    @Delete("DELETE FROM company_info WHERE user_id = #{userId}")
    int deleteByUserId(Long userId);
}
